package club.hicode.daydayup.init;

import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * 初始化测试
 * ﻿ ApplicationListener<ContextRefreshedEvent>
 *
 * @author Liu Chunfu
 * @date 2018-05-08 下午4:31
 **/
@Component
public class TestInit implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private TestService testServicel;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        Object source = event.getSource();
        System.out.println("source:" + source);
        ApplicationContext applicationContext = event.getApplicationContext();
        TestService bean = applicationContext.getBean(TestService.class);
        System.out.println(bean == testServicel);
        System.out.println("hhhhhhhhh");
        testServicel.say();
    }
}
